<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理员添加</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <include file="Index/common_css"/>
    <link href="__PUBLIC__/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
</head>

<body>
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <form action="" method="post" class="form form-horizontal" id="form-admin-role-add" onsubmit="return false">

            <div class="form-group">
                <label class="col-sm-3 control-label">管理员名称：</label>
                <div class="col-sm-8">
                    <input id="user_name" name="user_name" value="{$data.user_name}" class="form-control" type="text"  datatype="*4-16" nullmsg="不能为空">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">登陆邮箱：</label>
                <div class="col-sm-8">
                    <input id="user_email" name="user_email" value="{$data.user_email}" class="form-control" type="text"  datatype="*4-16" nullmsg="不能为空">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">登陆密码：</label>
                <div class="col-sm-8">
                    <input id="user_password" name="user_password" value="" class="form-control" type="text"  datatype="*4-16" placeholder="不改留空">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">手机号：</label>
                <div class="col-sm-8">
                    <input id="user_phone" name="user_phone" value="{$data.user_phone}"  class="form-control" type="text"  datatype="*4-16" nullmsg="不能为空">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">角色名称：</label>
                <div class="col-sm-8">
                    <select class="form-control" name="user_role" id="user_role">
                        <option value="2" <if condition="$data.role_id eq 2">selected="selected"</if> >CS管理员</option>
                        <option value="3"  <if condition="$data.role_id eq 3">selected="selected"</if>>报表管理</option>
                        <option value="4"  <if condition="$data.role_id eq 4">selected="selected"</if>>超级管理员</option>
                    </select>
                </div>
            </div>




            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <button type="button" class="btn btn-success radius"  onclick="getCheckAdIds(this,'{$data.user_id}')" id="admin-role-save" name="admin-role-save">
                        <i class="icon-ok"></i> 确定
                    </button>

                    <a style="margin-left: 20px;"onclick="layer_close();" class="btn btn-success btn-warning">
                        <i class="icon-ok"></i> 返回
                    </a>
                </div>
            </div>
        </form>
    </div>
</div>
<!-- 全局js -->
<include file="Index/common_js"/>
<!-- Peity -->

<!-- 自定义js -->
<script src="__PUBLIC__/admin/js/content.js?v=1.0.0"></script>
<script src="__PUBLIC__/common/js/layer_show.js"></script>

<!-- iCheck -->
<script src="__PUBLIC__/admin/js/plugins/iCheck/icheck.min.js"></script>
<!-- Peity -->
<script>

    function getCheckAdIds(obj,id) {
        var user_name= $("#user_name").val();
        var user_email= $("#user_email").val();
        var user_password= $("#user_password").val();
        var user_phone= $("#user_phone").val();
        var user_role= $("#user_role").val();

        if(user_name=='' || user_email==''|| user_phone==''||user_role=='') {
            layer.msg('不能有任何为空');
        } else {
            var index = layer.load();
            $.ajax({
                type:"POST",
                url:"__MODULE__/Admin/admin_saveData",
                dataType:'json',
                data:{id:id,user_name:user_name,user_email:user_email,user_password:user_password,user_phone:user_phone,user_role:user_role},
                success:function(data){
                    //console.log(data);
                    //alert(JSON.stringify(data));return;
                    layer.close(index);
                    if(data.status==1){
                        layer.msg(data.msg);
                        setTimeout(function () {location.reload();}, 1000);
                    }else if(data.status==0){
                        layer.msg(data.msg,{icon: 2, time: 2000});
                    }else{
                        layer.msg('网络错误',{icon: 2, time: 2000});
                    }
                },error:function(err){
                    //console.log(err);
                    layer.close(index);
                    layer.msg('error:网络错误',{icon: 2, time: 2000});
                }
            });
        }
    }
</script>
</body>
</html>
